from selenium import webdriver
from selenium.webdriver.common.by import By
import time
#调用包

class Driver1:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://ecshop.test2.shopex123.com/')
        #初始化对象属性

    def Id(self):
        #定位到搜索栏并写入类容
        self.driver.find_element(By.ID, 'keyword').send_keys('资生堂')
        #定位到搜索按钮点击进入
        self.driver.find_element(By.NAME, 'imageField').click()
        #打印标题类容
        print(self.driver.title)
        #创建一个注册方法
    def Class(self):
        #定位到注册按钮点击进入
        self.driver.find_element(By.CLASS_NAME, 'reg').click()
        #定位到账号输入类容
        self.driver.find_element(By.ID, 'username').send_keys('zhuzhu11')
        #定位到邮箱输入类容
        self.driver.find_element(By.ID, 'email').send_keys('1194971161@qq.com')
        #定位到密码输人类容
        self.driver.find_element(By.ID, 'password1').send_keys('123456')
        #定位到确认密码输入类容
        self.driver.find_element(By.ID, 'confirm_password').send_keys('123456')
        #定位到注册按钮点击注册
        self.driver.find_element(By.CLASS_NAME, 'signup_button').click()
        #创建一个登录方法
    def RegisTered(self):
        #定位到登录按钮点击登录
        self.driver.find_element(By.CLASS_NAME, 'sign').click()
        #定位到账号输入账号
        self.driver.find_element(By.XPATH, "//input[@style='border:0']").send_keys('zhuzhu11')
        #定位到密码输入密码
        self.driver.find_element(By.XPATH, "//input[@placeholder='密码']").send_keys('123456')
        #定位到登录点击登录
        self.driver.find_element(By.XPATH, "//input[@value='登 录' and @type='submit']").click()
    #定义一个关闭类
    def quit(self,seconds=3):
        time.sleep(seconds)
        self.driver.quit()
if __name__ == '__main__': #调用类和方法
    driver = Driver1()
    # driver.Id()
    # driver.Class()
    driver.RegisTered()
    driver.quit()











